package com.cl.ks.entity;


import com.cl.ks.annotation.GenerateMVC;
import com.cl.mvc.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

@Entity
@Table(name = "ks_flow_graph_record")
@org.hibernate.annotations.Table(appliesTo = "ks_flow_graph_record", comment = "流程图执行记录表")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@GenerateMVC
public class KsFlowGraphRecord extends BaseEntity implements Serializable {
    @ApiModelProperty("流程图id")
    @Column(name = "ks_flow_graph_id")
    private Integer ksFlowGraphId;
    @ApiModelProperty("状态")
    private Integer status;
    @ApiModelProperty("定时/手动")
    private Boolean taskFlag;
    @ApiModelProperty("定时任务id")
    @Column(name = "ks_flow_task_id")
    private Integer ksFlowTaskId;
    @ApiModelProperty("结束时间")
    private LocalDateTime endTime;
    @Column(name = "ks_flow_graph_json",columnDefinition = "longtext")
    @ApiModelProperty("流程图JSON")
    private String ksFlowGraphJson;

    @OneToMany(mappedBy = "ksFlowGraphRecord",cascade = CascadeType.REMOVE)
    @JsonIgnore
    @ApiModelProperty("关联日志")
    @ToString.Exclude
    private List<KsFlowGraphLog> ksFlowGraphLogList;

    @OneToMany(mappedBy = "ksFlowGraphRecord",cascade = CascadeType.REMOVE)
    @JsonIgnore
    @ApiModelProperty("关联结果")
    @ToString.Exclude
    private List<KsFlowResult> ksFlowResultList;

    @JoinColumn(name = "ks_flow_task_id",referencedColumnName = "id",insertable = false,updatable = false)
    @ManyToOne
    @JsonIgnoreProperties({"ksFlowGraphRecordList"})
    @ApiModelProperty("关联任务")
    private KsFlowTask ksFlowTask;
    @JoinColumn(name = "ks_flow_graph_id",referencedColumnName = "id",insertable = false,updatable = false)
    @ManyToOne
    @JsonIgnoreProperties({"ksFlowGraphRecordList"})
    @ApiModelProperty("关联流程图")
    private KsFlowGraph ksFlowGraph;


}
